# 定义接口对象层----角色管理
import requests


class ZshjRoleMangerApi(object):
    # 定义添加员工方法
    def add_role(self, req_heder, req_body):
        # 添加角色
        resp = requests.post(url="http://192.168.43.115:1111/admin/system/sysRole/save",
                             headers=req_heder,
                             json=req_body)

        return resp

    # 定义查询角色方法
    def query_role(self, role_id, req_heder):
        # 查询角色
        resp = requests.get(url="http://192.168.43.115:1111/admin/system/sysRole/get/" + role_id,
                            headers=req_heder)
        return resp

    # 定义修改角色方法
    def role_update(self, req_heder, req_body):
        # 修改角色
        resp = requests.put(url="http://192.168.43.115:1111/admin/system/sysRole/update",
                            headers=req_heder,
                            json=req_body)

        return resp

    def role_delete(self, req_heder, role_id):
        # 删除角色
        resp = requests.delete(url="http://192.168.43.115:1111/admin/system/sysRole/remove/" + role_id,
                               headers=req_heder)

        return resp


if __name__ == '__main__':
    # 创建实例化
    zshjrole = ZshjRoleMangerApi()
    # 准备请求头
    req_header = {
        "token": "eyJhbGciOiJIUzUxMiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAAAKtWKi5NUrJScgwN8dANDXYNUtJRSq0oULIyNDcwNjExtTC01FEqLU4t8kwBikGYeYm5qUAtiSm5mXlKtQB2PL6VQgAAAA.fszietAhTSkoGJ1MhPB01BarWOrw9CtyYKT0QGwNrpJfBZHm94F3OzPruvyRDTJ9wZrn7_Ak5oLnLqR20Tpltw"}
    # 准备请求体
    # req_body={"roleName": "靳勇", "roleCode": "6666"}
    # 调用
    # res=zshjrole.add_role(req_header,req_body)
    # role_id="9"
    # res=zshjrole.query_role(role_id,req_header)
    req_body = {"id": "10", "roleName": "靳勇", "roleCode": "7777"}
    # print(res.json())
